import { reactive } from 'vue';

/**
 * 表单调拨设备长度校验
 */
const assetListLengthValidator = (list: AppSysAssetChange.AssetDto[]) => list.length > 0;

const formRules = {
  changeTime: [{ required: true, message: '请选择调拨时间' }],
  deptId: [{ required: true, message: '请选择调出部门' }],
  allocationDeptId: [{ required: true, message: '请选择调入部门' }],
  userId: [{ required: true, message: '请选择调拨人' }],
  signUserId: [{ required: true, message: '请选择签收人' }],
  assetList: [
    {
      validator: assetListLengthValidator,
      message: '请选择调拨设备',
    },
  ],
};

const state = reactive<{
  /**
   * 调出部门选择器是否显示
   */
  deptCascaderIsShow: boolean;
  /**
   * 调入部门选择器是否显示
   */
  allocationDeptCascaderIsShow: boolean;
  /**
   * 调拨日历是否显示
   */
  changeTimeCalendarIsShow: boolean;
  /**
   * 签收人弹出框选择器是否显示
   */
  signUserPopupIsShow: boolean;
  /**
   * 资产列表弹出层是否显示
   */
  appAssetListPopupIsShow: boolean;
}>({
  deptCascaderIsShow: false,
  allocationDeptCascaderIsShow: false,
  changeTimeCalendarIsShow: false,
  signUserPopupIsShow: false,
  appAssetListPopupIsShow: false,
});

export { formRules, state };
